package com.group4.DB;

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.mysql.jdbc.*;

public class ConnectionManager {
	
	static Connection conn = null;
	private static final String USER = "project4";
	private static final String PASS = "s5r2avAG";
	private static final String DB_URL = "jdbc:mysql://titan.cmpe.boun.edu.tr:3306/database4";
	
	static{
		try {
			Class.forName("com.mysql.jdbc.Driver");
			conn = DriverManager.getConnection(DB_URL, USER, PASS);
			System.out.println("connected to DB");
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			System.out.println("SQL exception in creating connection");
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			System.out.println("Class not found exception in creating connection");
			e.printStackTrace();
		}
	}

	public static void closeConnection() {
		try {
			if (conn != null) {
				conn.close();
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
